<template>
   
      <div id="myChart" style="width: 600px;height:400px;"></div>
   
</template>
<script>
export default {
  data () {
    return {
      msg: 'Welcome to Your Vue.js App',
      dataChart: {
        date: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
        addTotal: [820, 932, 901, 934, 1290, 1330, 1320],
        updateTotal: [820, 32, 9, 94, 120, 130, 1320],
        deleteTotal: [820, 332, 1, 934, 290, 133, 120],
      },
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() > Date.now();
        },
        shortcuts: [
          {
            text: "今天",
            onClick(picker) {
              picker.$emit("pick", new Date());
            },
          },
          {
            text: "昨天",
            onClick(picker) {
              const date = new Date();
              date.setTime(date.getTime() - 3600 * 1000 * 24);
              picker.$emit("pick", date);
            },
          },
          {
            text: "一周前",
            onClick(picker) {
              const date = new Date();
              date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", date);
            },
          },
        ],
      },
      value: "2021-3",
    }
  },
  mounted(){
    this.drawLine();
  },
  methods: {
     updateeCharts() {
      var _this = this;
      //初始化数据
      let data = new Date(_this.value);
      let newdata = data.getFullYear() + "-" + (Number(data.getMonth())+1);
      this.$http
        .get("/operlog/queryOperLog?dateTime=" + newdata)
        .then(function (response) {
          _this.dataChart = response.data.data;
          _this.drawLine();
        });
    },
    drawLine(){
        // 基于准备好的dom，初始化echarts实例
        let myChart = this.$echarts.init(document.getElementById('myChart'))
        // 绘制图表
        myChart.setOption({
            title: { text: '在Vue中使用echarts' },
            tooltip: {},
            xAxis: {
                data: ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"]
            },
            yAxis: {},
            series: [{
                name: '销量',
                type: 'bar',
                data: [5, 20, 36, 10, 10, 20]
            }]
        });
    }
  }
}
</script>
<style>
</style>